package com.rika.controller;

import com.rika.pojo.Category;
import com.rika.pojo.PayRecord;
import com.rika.pojo.StockRecord;
import com.rika.response.QueryResult;
import com.rika.response.Result;
import com.rika.service.PayRecordService;
import com.rika.util.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class PayRecordController {
    @Resource
    private PayRecordService payRecordService;

    @RequestMapping("selectPayRecord")
    public Result selectPayRecord(String orderCode,String date,Integer pay_Type){
        Result result=new Result();
        Map<String,Object> params=new HashMap<>();
        String startTime="";
        String endTime="";
        if(date.length()>0){
            String[] Date=date.split("~");
            startTime=Date[0].trim();
            endTime=Date[1].trim();
        }
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        params.put("orderCode",orderCode);
        params.put("pay_Type",pay_Type);
        List<PayRecord> list=payRecordService.selectPayRecord(params);
        result.setCode(200);
        result.setData(list);
        return result;
    }
    @RequestMapping("selectRandEForR")
    public Result selectRandEForR(String date){
        Result result=new Result();
        String[] Date=date.split("~");
        Map<String,Object> params=new HashMap<>();
        params.put("startTime",Date[0].trim());
        params.put("endTime",Date[1].trim());
        List<PayRecord> list=payRecordService.selectRandEForR(params);
        result.setCode(200);
        result.setData(list);
        return result;
    }
    @RequestMapping("selectRandEForE")
    public Result selectRandEForE(String date){
        Result result=new Result();
        String[] Date=date.split("~");
        Map<String,Object> params=new HashMap<>();
        params.put("startTime",Date[0].trim());
        params.put("endTime",Date[1].trim());
        List<PayRecord> list=payRecordService.selectRandEForE(params);
        result.setCode(200);
        result.setData(list);
        return result;
    }
}
